﻿/* texturefill.h
 * 
 * Copyright (C) 2022 Yuan LI
 * email:18069211@qq.com
 * https://blog.csdn.net/liyuanbhu
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or (at
 * your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifndef TEXTUREFILL_H
#define TEXTUREFILL_H

#include <QImage>

/**
 * @brief The TextureFill class 漫水填充算法的一个简单实现。只能处理 RGB32 图像。
 *
 */
class TextureFill
{
public:
    TextureFill();
    /**
     * @brief fillColor 漫水填充算法。将一个联通的同色区域填充为一种指定的颜色。
     * @param image 待填充的图像。必须是 RGB32 的。
     * @param seedPoint 初始点。填充与整个初始点联通的同色区域。
     * @param fillColor 要填充的颜色。
     * @param type 4 或 8 ，表示 4 连通域或者 8 连通域。
     * @return
     */
    bool fillColor(QImage &image, QPoint seedPoint, QRgb fillColor, int type = 8);//type = 4 或 8
    /**
     * @brief fillTexture 漫水填充算法。将一个联通的同色区域填充上一个特殊的图案。
     * @param image 待填充的图像。必须是 RGB32 的。
     * @param seedPoint 初始点。填充与整个初始点联通的同色区域。
     * @param texture 要填充的图案，也必须是 RGB32 的。
     * @param type type 4 或 8 ，表示 4 连通域或者 8 连通域。
     * @return
     */
    bool fillTexture(QImage &image, QPoint seedPoint, QImage &texture, int type = 8);
};

#endif // TEXTUREFILL_H
